package cn.yuanqiao.quartz.task;

import cn.yuanqiao.common.utils.DateUtils;
import cn.yuanqiao.es.service.ElasticsearchApiService;
import cn.yuanqiao.quartz.util.MethodDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 全量索引任务
 *
 * @ProjectName: JZSDAS
 * @Package: cn.yuanqiao.job.task
 * @ClassName: ESCompleteTask
 * @Author: lenovo
 * @Description: hbWang
 * @Date: 2023/11/22 16:37
 * @Version: 1.0
 * */


@Component("esCompleteTask")
public class ESCompleteTask {
    private static final Logger log = LoggerFactory.getLogger(ESCompleteTask.class);
    @Autowired
    ElasticsearchApiService remoteEsAptService;

    @MethodDescription("ES搜索引擎创建全量索引定时任务，arg0需要传入tenantCode")
    public void search(String tenantCode) {
        Date start = new Date();
        log.info("全量索引任务开始="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,start));
        remoteEsAptService.completeIndexJob(tenantCode);
        Date end = new Date();
        log.info("全量索引任务结束="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,end));
        log.info("耗时="+(end.getTime()-start.getTime())+"毫秒");
    }


}
